/**
 * 
 */
package com.yonder.agenda.rest;

import java.util.List;

import javax.ws.rs.Consumes;
import javax.ws.rs.GET;
import javax.ws.rs.PUT;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import com.yonder.agenda.entity.Telephone;
import com.yonder.agenda.service.TelephoneService;

/**
 * REST services for {@link Telephone} entity.
 * 
 * @author CosminS
 * @since Feb 3, 2014
 */
@Component
@Path("telephones")
public class TelephoneRestService {
	
	/**
	 * Injected {@link TelephoneService}.
	 */
	@Autowired
	private TelephoneService telephoneService;
	
	/**
	 * .
	 * 
	 * @return .
	 */
	@GET
	@Path("/getTelephones")
	@Produces(MediaType.APPLICATION_JSON)
	public Response getAllTelephones() {
		List<Telephone> telephonesList = telephoneService.findAll();
		return Response.ok(telephonesList).build();
	}
	
	/**
	 * .
	 * 
	 * @param persisted
	 *            .
	 * @return .
	 */
	@Path("/addTelephone")
	@PUT
	@Produces(MediaType.APPLICATION_JSON)
	@Consumes(MediaType.APPLICATION_JSON)
	public Telephone addTelephone(Telephone persisted) {
		persisted = telephoneService.create(persisted);
		return persisted;
	}
}